;(()=>{
    let [infoLine,infoBox,oldInfoCon] = ['.info_line','.info_Box',$('.info_Box').children()];
    let [infoLineS,infoBoxS,oldInfoConS] = ['.info_lineS','.info_BoxS',$('.info_BoxS').children()];
    //---------------------------------------------------------------------------------------------
    //中心内容下方的切换
    let[infoLineT,detailBox,oldDetailCon] = ['.Detail_readBox .info_line','.conBox_list',$('.conBox_list').children()];
    let circulateFn = (time,fatherDom,childDom)=>{
        for(let i = 0;i<time;i++){
            $(fatherDom).append(childDom);
        }
    };
    let infoCon = `
                <div class="info_con">
                    <div class="info_conLeft">
                        <a href="javascript:;">
                            <img src="images/avatar_2.jpg" alt="" width="86" height="86">
                        </a>
                    </div>
                    <div class="info_conRight">
                        <a href="javascript:;">
                            <p>今日淘汰鸡价格如何？2019全国最新淘汰鸡价格行情汇总今日淘汰鸡价格如何？2019全国最新淘汰鸡价格行情汇总</p>
                        </a>
                    </div>
                </div>`;
    let readCon = `
        <a href="javascript:;" target="_blank" class="list_dom">
            <div class="left">
                <img src="images/avatar_2.jpg" alt="" width="86" height="86">
            </div>
            <div class="right">
                <div class="right_top">
                    <p>目前淘汰鸡多少钱一斤？2019全国最新淘汰鸡价格行情汇总</p>
                </div>
                <div class="right_bottom">
                    <span class="left">畜牧水产.2019-02-27</span>
                    <span class="right">97人阅读</span>
                </div>
            </div>
        </a>
    `;
    let PriceDomCon = `
        <a href="javascript:;" target="_blank" class="price_dom">
            <div class="top">
                <img src="images/avatar_1.jpg" alt="" width="210" height="160">
            </div>
            <div class="middle">￥0.5/株</div>
            <div class="bottom">
                <div>红油香椿苗 2公分以下</div>
                <span class="left">山东泰安岱岳区</span>
                <span class="right">3小时前</span>
            </div>
      </a>
    `;
    let agriAniFn = (Nodes,iB,iL,oldC,newC,st,fin,count,dnewC,dfin)=>{
            $(Nodes).each((index,ele)=>{
                $(ele).on('mouseenter', () => {
                if($(ele).hasClass('info_active')){
            }else{
                $(ele).addClass('info_active').siblings().removeClass('info_active');
                if(index === 0){
                    $(iB).children().remove();
                    circulateFn(count,iB,oldC);
                    $(iL).stop().animate({'left':st},300);
                }else if(index === 1){
                    $(iB).children().remove();
                    circulateFn(count,iB,newC);
                    $(iL).stop().animate({'left':fin},300);
                }else{
                    $(iB).children().remove();
                    circulateFn(count,iB,dnewC);
                    $(iL).stop().animate({'left':dfin},300);
                }
            }
        });
        });

    };
    //中心内容右边效果
    agriAniFn('.info_top span',infoBox,infoLine,oldInfoCon,infoCon,0,115,5,null,0);
    agriAniFn('.info_topS span',infoBoxS,infoLineS,oldInfoConS,infoCon,0,115,5,null,0);
    //----------------------------------------------------------------------
    //新闻内容下方效果
    agriAniFn('.readBox_title span',detailBox,infoLineT,oldDetailCon,readCon,0,115,6,PriceDomCon,228);
    
})();
/*
*   轮播图代码
* */
(()=>{
    let oContent=document.getElementById('nowPro_Con');
    let spanArr=oContent.children[1].children;
    let oUl=oContent.children[0];
    let newLi=oUl.children[0].cloneNode(true);
    let square=0;//通过square来模拟spanArr索引值，以此点亮盒子
    let k=0;//通过key来模拟图片索引值，以此来移动ul
    spanArr[0].className='current';
    oUl.appendChild(newLi);//复制第一张图并添加到第五张图后面
    let timer;
    for(let i=0;i<spanArr.length;i++){
        spanArr[i].index=i;
        spanArr[i].onmouseenter=function(){
            for (let j = 0; j < spanArr.length; j++) {
                spanArr[j].className='';
            }
            this.className='current';
            k = square = this.index;
            fn(oUl,-this.index*336);
        }
    }
    //5
     timer = setInterval(autoPlay,1000);
    oContent.onmouseenter=function(){
        clearInterval(timer);
    }
    oContent.onmouseleave=function(){
        timer=setInterval(autoPlay,1000);
    }

    function autoPlay(){
        k++;//图片的索引值
        if(k>5){
            //图片已经滑动到最后一张时，接下来跳转到第一张，然后滑动到第二张.
            oUl.style.left=0;//让图片瞬间回到第一张而不是改变图片的索引值
            k=1;//让他跳转到第二张
        }
        fn(oUl,-k*336);
        square++;//span的索引值
        if(square>spanArr.length-1){
            square=0;
        }
        for(let i=0;i<spanArr.length;i++){
            spanArr[i].className='';
        }
        spanArr[square].className='current';


    }
    function fn(ele,target){
        let speed;
        let val;
        clearInterval(ele.timer);
        speed=target>ele.offsetLeft?10:-10;
        ele.timer=setInterval(function(){
            ele.style.left=ele.offsetLeft+speed+'px';
            val=target-ele.offsetLeft;
            if(Math.abs(val)<Math.abs(speed)){
                ele.style.left=target+'px';
                clearInterval(ele.timer);
            }
        },10);
    }
    oContent.onmouseenter=function(){
        oContent.children[2].style.display='block';
        clearInterval(timer);
    }
    oContent.onmouseleave=function(){
        oContent.children[2].style.display='none';
        timer=setInterval(autoPlay,1000);
    }
    oContent.children[2].children[0].onclick=function(){
        k--;
        if(k<0){
            oUl.style.left=-500*(spanArr.length)+'px';
            k=spanArr.length-1;
        }
        fn(oUl,-k*336);
        square--;
        if(square<0){
            square=4;
        }
        for(let i=0;i<spanArr.length;i++){
            spanArr[i].className='';
        }
        spanArr[square].className='current';
    }
    oContent.children[2].children[1].onclick=function(){
        autoPlay();

    }




})();
/*
*   以上是详情页面的JS
 */
